
import { defineStore } from "pinia"
import store from '@/store'
import { TStore } from "../typings"
/** 应用程序全局状态 */
export const useAppStore = defineStore('app-store', {
    state: (): TStore.AppStore => ({
        title: '教师成绩统计',
        layoutMode: 'vertical',
        collapse: false,
        showAside: true,
        showLogo: true,
        showBreadcrumb: true,
        breadcrumbIcon: true,
        showFooter: true,
    }),
    getters: {
        // 显示模式
        layout: (state) => state.layoutMode,
        // 顶部是否显示菜单
        topHasMenu: (state) => state.layout === 'horizontal' && state.showAside,
        // 是否有侧边栏
        hasAside: (state) => state.layout === 'vertical' && state.showAside,
    },
    actions: {
        // 切换折叠状态
        toggleCollapse() {
            this.collapse = !this.collapse
        },
        // 切换布局模式
        switchLayout(layout: TStore.LayoutType) {
            this.layout = layout
            // 实现切换布局模式
        },
        // 设置标题
        setTitle(title: string) {
            this.title = title
            // 设置APp的标题
        }
    }
})

/** Setup 外使用 */
export function useAppStoreHook() {
    return useAppStore(store)
}


